package tq.com.tqstudent.net;

import com.google.gson.Gson;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;

public class SCNetInterface {

    static public void register(String name, String pwd, String code, SCHttpCallback pCallback){
        HashMap<String, String> param = new HashMap<>();
        param.put("username", name);
        param.put("password", pwd);
        param.put("aup", "1");
        if(code != null && code.length() > 0){
            param.put("invitecode", code);
        }

        SCHttpClient.httpClient().postWithUrlEncode(SCHttpClient.fullUrl("/api/user/signup"), param, pCallback);
    }

    static public void login(String name, String pwd, SCHttpCallback pCallback){
        HashMap<String, String> param = new HashMap<>();
        param.put("name", name);
        param.put("pwd", pwd);

//        SCLogin.shareInstance().cleanToken();
        String par = new Gson().toJson(param);
        SCHttpClient.httpClient().postJson(SCHttpClient.fullUrl("/api/user/session"), par, pCallback);
    }

    static public void logout(SCHttpCallback pCallback){
        SCHttpClient.httpClient().get(SCHttpClient.fullUrl("/logout"), null, pCallback);
    }


}
